/*
 * @Author: wangqizhang
 * @Date: 2024-04-26 15:07:13
 * @LastEditors: wangqizhang
 * @LastEditTime: 2024-04-29 16:52:30
 * @FilePath: /suixinji-server/router/user.root.js
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
const Router = require('koa-router');
const router = new Router({ prefix: '/user' });
const { register, login } = require('../controller/user.controller');
const {
  encryptPassword,
  validateUser,
  validHasUser,
} = require('../middleWare/user.mw');
const { validBodyData } = require('../middleWare');
const { userParams } = require('../model/user.model');
router.post(
  '/register',
  (ctx, next) => validBodyData(ctx, next, userParams),
  validateUser,
  encryptPassword,
  register
);
router.get('/', (ctx, next) => {
  ctx.body = 'hahahahahahah';
});
router.post(
  '/login',
  (ctx, next) => validBodyData(ctx, next, userParams),
  validHasUser,
  login
);
module.exports = router;
